﻿using Microsoft.AspNetCore.Builder;

namespace OnHook.Framework.Module
{
    /// <summary>
    /// 模块基类
    /// </summary>
    public abstract class ModuleBase : IModule
    {
        /// <summary>
        /// 模块类型
        /// </summary>
        public abstract  ModuleType ModuleType { get; }

        /// <summary>
        /// 加载顺序
        /// </summary>
        public virtual int Sort => (int)ModuleType;

        /// <summary>
        /// 初始化
        /// </summary>
        public virtual void Init() { }

        /// <summary>
        /// 初始化后
        /// </summary>
        public virtual void PostInit(IApplicationBuilder app) { }

        /// <summary>
        /// 预处理
        /// </summary>
        /// <param name="model"></param>
        public virtual void PreInit(BootParams model) { }
    }

    /// <summary>
    /// 核心组件模块，最优先加载初始化
    /// </summary>
    public abstract class FrameModule : ModuleBase, IFrameModule
    {
        /// <summary>
        /// 
        /// </summary>
        public override ModuleType ModuleType => ModuleType.FrameModule;
    }
    /// <summary>
    /// 程序模块，最后加载初始化
    /// </summary>
    public abstract class ProgrameModule : ModuleBase, IFrameModule
    {
        /// <summary>
        /// 
        /// </summary>
        public override ModuleType ModuleType => ModuleType.ProgrameModule;

    }
    /// <summary>
    /// 其他组建模块，比核心模块晚加载，优先程序模块加载
    /// </summary>
    public abstract class ComponentModule : ModuleBase, IFrameModule
    {
        /// <summary>
        /// 
        /// </summary>
        public override ModuleType ModuleType => ModuleType.ComponentModule;
    }
}
